window._MRMN = {

    selectNmb:{
        'D':'100',
        'C':'200',
        'B':'300',
        'A':'400',
        'S':'500',
        'SS':'600'
    },

    selectQua:{
        ren:'ziyou',
        yao:'gongli',
        xian:'xinyang'
    },

    randomTeam:function(mapname){
        var team = [];
        var mapconf = _NPCMAP[mapname];
        var armyNmb = mapconf.baseNmb;//基础人数
        var selectValueMap = _GAMEDATAHELPER.getSelectValue();
        var npcObj = _MRMN.getBossAndNpc(mapname,selectValueMap);
        if(npcObj.boss.length>0){
            team.push(_CU.randomObj(npcObj.boss));
            armyNmb--;
        }

        for(var i=0;i<armyNmb;i++){
            team.push(_CU.randomObj(npcObj.npc));
        }

        return team;
    },

    canMeet:function(npcname){
        var npcdataconf = _NPC[npcname];
        if(!npcdataconf.isboss){
            return true;
        }else{
            var selectValueMap = _GAMEDATAHELPER.getSelectValue();
            if(selectValueMap){
                if(npcdataconf.race!='mo'){
                    var datavalue = selectValueMap[_MRMN.selectQua[npcdataconf.race]];
                    var needvalue = _MRMN.selectNmb[npcdataconf.level];
                    if(datavalue>=needvalue){
                        return true;
                    }
                }else{
                    return selectValueMap['ziyou']==500
                            &&selectValueMap['gongli']==500
                            &&selectValueMap['xinyang']==500
                }
            }else{
                return true;
            }
        }
        return false;
    },

    getBossAndNpc:function(mapname,selectValueMap){
        var mapconf = _NPCMAP[mapname];
        var mapnpc = mapconf.npc;
        var boss = [];
        var npc = [];
        for(var i=0;i<mapnpc.length;i++){
            var npcconf = mapnpc[i];
            var npcname = npcconf.npc;
            if(_MRMN.canMeet(npcname)){
                var npcdataconf = _NPC[npcname];
                if(!npcdataconf.isboss){
                    npc.push(npcname);
                }else{
                    boss.push(npcname);
                }
            }
        }
        if(npc.length<=0){
            console.log(mapname,'缺少小怪');
        }
        return {npc:npc,boss:boss};
        
    }

}